#include <glib.h>

gint main(gint argc, gchar **argv)
{
    GList *list = NULL;
    GList *l = NULL;
#if 1
    list = g_list_append(list, GINT_TO_POINTER(1));
    list = g_list_append(list, GINT_TO_POINTER(3));
    list = g_list_append(list, GINT_TO_POINTER(5));
    list = g_list_append(list, GINT_TO_POINTER(7));
#endif
    l = g_list_last(list);
    g_print("last element: %d \n", (NULL == l) ? 99999 : GPOINTER_TO_INT(l->data));

    l = g_list_previous(l);
    g_print("last->prev element: %d \n", (NULL == l) ? 99999 : GPOINTER_TO_INT(l->data));

    l = g_list_first(list);
    g_print("first element: %d \n", (NULL == l) ? 99999 : GPOINTER_TO_INT(l->data));

    l = g_list_next(l);
    g_print("first->next element: %d \n", (NULL == l) ? 99999 : GPOINTER_TO_INT(l->data));

    g_list_free(list);

    return 0;
}